using System.Collections.Generic;
using OracleInternal.SqlAndPlsqlParser.LocalParsing;

namespace OracleInternal.SqlAndPlsqlParser.RuleProcessors.ODPCommands
{
	internal static class OracleMbEarleySqlStmtRuleMultiProcessors
	{
		public static OracleMbEarleyRuleMultiProcessorAddItem[] s_vRuleProcessorItems;

		static OracleMbEarleySqlStmtRuleMultiProcessors()
		{
			OracleMbEarleyRuleMultiProcessorAddItem[] array = new OracleMbEarleyRuleMultiProcessorAddItem[4];
			OracleMbEarleyRuleMultiProcessorAddItem oracleMbEarleyRuleMultiProcessorAddItem = new OracleMbEarleyRuleMultiProcessorAddItem
			{
				m_vHeadSymbol = "sql_stmt",
				m_vRHSSymbols = new string[1]
				{
					"sql_query_or_dml_stmt"
				},
				m_vRuleProcessor = Process_SqlStmt_SqlQueryOrDmlStmt_Rule,
				m_vAddType = OracleMbEarleyRuleMultiProcessorAddType.SpecificRule
			};
			array[0] = oracleMbEarleyRuleMultiProcessorAddItem;
			oracleMbEarleyRuleMultiProcessorAddItem = new OracleMbEarleyRuleMultiProcessorAddItem
			{
				m_vHeadSymbol = "sql_stmt",
				m_vRHSSymbols = new string[1]
				{
					"fetch_statement"
				},
				m_vRuleProcessor = Process_SqlStmt_FetchStmt_Rule,
				m_vAddType = OracleMbEarleyRuleMultiProcessorAddType.SpecificRule
			};
			array[1] = oracleMbEarleyRuleMultiProcessorAddItem;
			oracleMbEarleyRuleMultiProcessorAddItem = new OracleMbEarleyRuleMultiProcessorAddItem
			{
				m_vHeadSymbol = "sql_stmt",
				m_vRHSSymbols = new string[1]
				{
					"open_cursor_reference_statement"
				},
				m_vRuleProcessor = Process_SqlStmt_OpenCursorReferenceStatement_Rule,
				m_vAddType = OracleMbEarleyRuleMultiProcessorAddType.SpecificRule
			};
			array[2] = oracleMbEarleyRuleMultiProcessorAddItem;
			oracleMbEarleyRuleMultiProcessorAddItem = new OracleMbEarleyRuleMultiProcessorAddItem
			{
				m_vHeadSymbol = "sql_stmt",
				m_vRHSSymbols = new string[1]
				{
					"open_statement"
				},
				m_vRuleProcessor = Process_SqlStmt_OpenStatement_Rule,
				m_vAddType = OracleMbEarleyRuleMultiProcessorAddType.SpecificRule
			};
			array[3] = oracleMbEarleyRuleMultiProcessorAddItem;
			s_vRuleProcessorItems = array;
		}

		public static object Process_SqlStmt_SqlQueryOrDmlStmt_Rule(OracleMbEarleyParserMultiContext ctx, int ruleMatchPosition)
		{
			List<LexerToken> tokens = ctx.Tokens;
			ParseNode currentParseNode = ctx.CurrentParseNode;
			int vBegin = tokens[currentParseNode.From].m_vBegin;
			int vEnd = tokens[currentParseNode.To].m_vEnd;
			((OracleLpParserContext)ctx).CurrentStatementText = new OracleLpTextFragment(ctx.Script, vBegin, vEnd - vBegin);
			OracleMbEarleyRuleMultiProcessorTable ruleProcessorTable = ctx.RuleProcessorTable;
			ctx.RuleProcessorTable = ctx.GetRuleProcessorTable("sql_query_or_dml_stmt");
			object result = OracleMbEarleyRuleMultiProcessor.ProcessNodeRules(currentParseNode, ctx.CurrentRuleIndex + 1, -1, ctx);
			ctx.RuleProcessorTable = ruleProcessorTable;
			return result;
		}

		public static object Process_SqlStmt_FetchStmt_Rule(OracleMbEarleyParserMultiContext ctx, int ruleMatchPosition)
		{
			OracleMbEarleyRuleMultiProcessorTable ruleProcessorTable = ctx.RuleProcessorTable;
			ctx.RuleProcessorTable = ctx.GetRuleProcessorTable("fetch_statement");
			object result = OracleMbEarleyRuleMultiProcessor.ProcessNodeRules(ctx.CurrentParseNode, ctx.CurrentRuleIndex + 1, -1, ctx);
			ctx.RuleProcessorTable = ruleProcessorTable;
			return result;
		}

		public static object Process_SqlStmt_OpenCursorReferenceStatement_Rule(OracleMbEarleyParserMultiContext ctx, int ruleMatchPosition)
		{
			OracleMbEarleyRuleMultiProcessorTable ruleProcessorTable = ctx.RuleProcessorTable;
			ctx.RuleProcessorTable = ctx.GetRuleProcessorTable("open_cursor_reference_statement");
			object result = OracleMbEarleyRuleMultiProcessor.ProcessNodeRules(ctx.CurrentParseNode, ctx.CurrentRuleIndex + 1, -1, ctx);
			ctx.RuleProcessorTable = ruleProcessorTable;
			return result;
		}

		public static object Process_SqlStmt_OpenStatement_Rule(OracleMbEarleyParserMultiContext ctx, int ruleMatchPosition)
		{
			OracleMbEarleyRuleMultiProcessorTable ruleProcessorTable = ctx.RuleProcessorTable;
			ctx.RuleProcessorTable = ctx.GetRuleProcessorTable("open_statement");
			object result = OracleMbEarleyRuleMultiProcessor.ProcessNodeRules(ctx.CurrentParseNode, ctx.CurrentRuleIndex + 1, -1, ctx);
			ctx.RuleProcessorTable = ruleProcessorTable;
			return result;
		}
	}
}
